\documentclass{report}

\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{color}

\title{\texttt{acados} reference}

\begin{document}

\maketitle

\chapter{Interfaces}

\section{OCP QP interface}
This interface describes a Quadratic Programming (QP) problem with Optimal Control Problem (OCP) structure, as follows:
\begin{subequations}
	\label{eq:OCP_QP}
	\begin{alignat}{3}
	\underset{\substack{x_0,\ldots,x_k \\ u_0,\ldots,u_{N-1}}}{\mathrm{minimize}} \quad & \sum_{k=0}^{N-1} \frac 1 2 \begin{bmatrix} x_k \\ u_k \end{bmatrix}^\top \begin{bmatrix} Q_k & S_k^\top \\ S_k & R_k \end{bmatrix} \begin{bmatrix} x_k \\ u_k \end{bmatrix} + &&\begin{bmatrix} q_k \\ r_k \end{bmatrix}^\top \begin{bmatrix} x_k \\ u_k \end{bmatrix} \\ & \qquad + \frac 1 2 x_N^\top Q_N x_N + q_N^\top x_N \nonumber \\
	\mathrm{subject~to} \quad & x_{k+1} = A_k x_k + B_k u_k + b_k, && k=0,\dots,N-1, \\
	& \underline u_k \leq u_k \leq \overline u_k, && k=0,\dots,N-1, \\
	& \underline x_k \leq x_k \leq \overline x_k, && k=0,\dots,N, \\
	& \underline c_k \leq C^x_k x_k + C^u_k u_k \leq \overline c_k, && k=0,\dots,N-1, \\
	& \underline c_N \leq C^x_N x_N \leq \overline c_N.
	\end{alignat}
\end{subequations}

\subsection{The \texttt{C} interface}
The interface is as follows:
\begin{verbatim}
int ocp_qp_NAME(ocp_qp_in *input, ocp_qp_out *output,
    ocp_qp_NAME_args *args, void *workspace);
\end{verbatim}
where \texttt{NAME} is the name of the specific solver.

\subsection{Return value}
The function returns an integer number, that is defined in the following enumeration:
\begin{description}
	\item[ACADOS\_SUCCESS] Solution successfully found.
	\item[ACADOS\_MAXITER] Maximum number of iterations reached.
	\item[ACADOS\_MINSTEP] Minumum step size reached (in IPs, probably infeasible problem).
\end{description}

\subsection{Data}
\label{sec:OCP_QP_interface_data}
\begin{description}
	\item[ocp\_qp\_in] The struct of OCP QP input data contains the following fields:
	\begin{description}
		\item[N] is the number of control intervals.
		\item[nx] is the vector of size $N+1$ of the state sizes $n_x$ at the different stages, such that \texttt{nx[k]} is the state size at stage \texttt{k}.
		\item[nu] is the vector of size $N$ of the input sizes $n_u$ at the different stages, such that \texttt{nu[k]} is the input size at stage \texttt{k}.
		\item[nb] is the vector of size $N+1$ of the bound sizes $n_b$ at the different stages, such that \texttt{nb[k]} is the bound size at stage \texttt{k}.
		The value of \texttt{nb[k]} is smaller or equal to \texttt{nx[k]+nu[k]}.
		\item[nc] is the vector of size $N+1$ of the general polytopic constraint sizes $n_c$ at the different stages, such that \texttt{nc[k]} is the general polytopic constraint size at stage \texttt{k}.
		\item[A] is the vector of size $N$ of the pointers to the first element of the matrices $A_k$, such that \texttt{A[k]} is the pointer to the first element of the matrix $A_k$, and \texttt{A[k][0]} is the first element of the matrix $A_k$.
		The matrix referenced by the pointer \texttt{A[k]} is stored in column-major order, in a vector of \texttt{nx[k+1]$\times$nx[k]} floating-point numbers.
		\item[B] is the vector of size $N$ of the pointers to the first element of the matrices $B_k$, such that \texttt{B[k]} is the pointer to the first element of the matrix $B_k$, and \texttt{B[k][0]} is the first element of the matrix $B_k$.
		The matrix referenced by the pointer \texttt{B[k]} is stored in column-major order, in a vector of \texttt{nx[k+1]$\times$nu[k]} floating-point numbers.
		\item[b] is the vector of size $N$ of the pointers to the first element of the vectors $b_k$, such that \texttt{b[k]} is the pointer to the first element of the vector $b_k$, and \texttt{b[k][0]} is the first element of the vector $b_k$.
		The vector referenced by the pointer \texttt{b[k]} is stored in a vector of \texttt{nx[k+1]$\times$1} floating-point numbers.
		\item[Q] is the vector of size $N+1$ of the pointers to the first element of the matrices $Q_k$, such that \texttt{Q[k]} is the pointer to the first element of the matrix $Q_k$, and \texttt{Q[k][0]} is the first element of the matrix $Q_k$.
		The matrix referenced by the pointer \texttt{Q[k]} is stored in column-major order, in a vector of \texttt{nx[k]$\times$nx[k]} floating-point numbers.
		\item[S] is the vector of size $N$ of the pointers to the first element of the matrices $S_k$, such that \texttt{S[k]} is the pointer to the first element of the matrix $S_k$, and \texttt{S[k][0]} is the first element of the matrix $S_k$.
		The matrix referenced by the pointer \texttt{S[k]} is stored in column-major order, in a vector of \texttt{nu[k]$\times$nx[k]} floating-point numbers.
		\item[R] is the vector of size $N$ of the pointers to the first element of the matrices $R_k$, such that \texttt{R[k]} is the pointer to the first element of the matrix $R_k$, and \texttt{R[k][0]} is the first element of the matrix $R_k$.
		The matrix referenced by the pointer \texttt{R[k]} is stored in column-major order, in a vector of \texttt{nu[k]$\times$nu[k]} floating-point numbers.
		\item[q] is the vector of size $N+1$ of the pointers to the first element of the vectors $q_k$, such that \texttt{q[k]} is the pointer to the first element of the vector $q_k$, and \texttt{q[k][0]} is the first element of the vector $q_k$.
		The vector referenced by the pointer \texttt{q[k]} is stored in a vector of \texttt{nx[k]$\times$1} floating-point numbers.
		\item[r] is the vector of size $N$ of the pointers to the first element of the vectors $r_k$, such that \texttt{r[k]} is the pointer to the first element of the vector $r_k$, and \texttt{r[k][0]} is the first element of the vector $r_k$.
		The vector referenced by the pointer \texttt{r[k]} is stored in a vector of \texttt{nu[k]$\times$1} floating-point numbers.
		\item[idxb] is the vector of size $N+1$ of the pointers to the first element of the integer vectors $\mathrm{idxb}_k$ describing the indexes of the corresponding upper and lower bounds in \texttt{lb} and \texttt{ub}, such that \texttt{idxb[k]} is the pointer to the index of the first bound at stage $k$, and \texttt{idxb[k][0]} is index of the first bound at stage $k$.
		The indexes in \texttt{idxb[k]} correspond to the position of the constrained components in the variables vector $\begin{bmatrix} x_k \\ u_k \end{bmatrix}$: therefore a bound on the first state component has index \texttt{0}, a bound on the last state component has index \texttt{nx[k]-1}, a bound on the first input component has index \texttt{nx[k]} and a bound on the last input component has index \texttt{nx[k]+nu[k]-1}.
		The vector referenced by the pointer \texttt{idxb[k]} is stored in a vector of \texttt{nb[k]$\times$1} integer numbers.
		\item[lb] is the vector of size $N+1$ of the pointers to the first element of the vectors of lower bounds, such that \texttt{lb[k]} is the pointer to the first element of the vector $\begin{bmatrix} \underline x_{k, \mathrm{idxb}_k} \\ \underline u_{k, \mathrm{idxb}_k} \end{bmatrix}$, and \texttt{lb[k][0]} is the first element of the vector $\begin{bmatrix} \underline x_{k, \mathrm{idxb}_k} \\ \underline u_{k, \mathrm{idxb}_k} \end{bmatrix}$.
		The vector referenced by the pointer \texttt{lb[k]} is stored in a vector of \texttt{nb[k]$\times$1} floating-point numbers.
		\item[ub] is the vector of size $N+1$ of the pointers to the first element of the vectors of lower bounds, such that \texttt{ub[k]} is the pointer to the first element of the vector $\begin{bmatrix} \overline x_{k, \mathrm{idxb}_k} \\ \overline u_{k, \mathrm{idxb}_k} \end{bmatrix}$, and \texttt{ub[k][0]} is the first element of the vector $\begin{bmatrix} \overline x_{k, \mathrm{idxb}_k} \\ \overline u_{k, \mathrm{idxb}_k} \end{bmatrix}$.
		The vector referenced by the pointer \texttt{ub[k]} is stored in a vector of \texttt{nb[k]$\times$1} floating-point numbers.
		\item[Cx] is the vector of size $N+1$ of the pointers to the first element of the matrices $C^x_k$, such that \texttt{Cx[k]} is the pointer to the first element of the matrix $C^x_k$, and \texttt{Cx[k][0]} is the first element of the matrix $C^x_k$.
		The matrix referenced by the pointer \texttt{Dx[k]} is stored in column-major order, in a vector of \texttt{nc[k]$\times$nx[k]} floating-point numbers.
		\item[Cu] is the vector of size $N$ of the pointers to the first element of the matrices $C^u_k$, such that \texttt{Cu[k]} is the pointer to the first element of the matrix $C^u_k$, and \texttt{Cu[k][0]} is the first element of the matrix $C^u_k$.
		The matrix referenced by the pointer \texttt{Cu[k]} is stored in column-major order, in a vector of \texttt{nc[k]$\times$nu[k]} floating-point numbers.
		\item[lc] is the vector of size $N+1$ of the pointers to the first element of the vectors $\underline c_k$, such that \texttt{lc[k]} is the pointer to the first element of the vector $\underline c_k$, and \texttt{lc[k][0]} is the first element of the vector $\underline c_k$.
		The vector referenced by the pointer \texttt{ld[k]} is stored in a vector of \texttt{nc[k]$\times$1} floating-point numbers.
		\item[uc] is the vector of size $N+1$ of the pointers to the first element of the vectors $\overline c_k$, such that \texttt{uc[k]} is the pointer to the first element of the vector $\overline c_k$, and \texttt{uc[k][0]} is the first element of the vector $\overline c_k$.
		The vector referenced by the pointer \texttt{uc[k]} is stored in a vector of \texttt{nc[k]$\times$1} floating-point numbers.
	\end{description}
	\item[ocp\_qp\_out] The struct of OCP QP output data contains the following fields:
	\begin{description}
		\item[x] is the vector of size $N+1$ of the pointers to the first element of the vectors $x_k$ (states), such that \texttt{x[k]} is the pointer to the first element of the vector $x_k$, and \texttt{x[k][0]} is the first element of the vector $x_k$.
		The vector referenced by the pointer \texttt{x[k]} is stored in a vector of \texttt{nx[k]$\times$1} floating-point numbers.
		\item[u] is the vector of size $N+1$ of the pointers to the first element of the vectors $u_k$ (controls or inputs), such that \texttt{u[k]} is the pointer to the first element of the vector $u_k$, and \texttt{u[k][0]} is the first element of the vector $u_k$.
		The vector referenced by the pointer \texttt{u[k]} is stored in a vector of \texttt{nu[k]$\times$1} floating-point numbers.
		\item[pi] is the vector of size $N$ of the pointers to the first element of the vectors $\pi_k$ (Lagrange multipliers of the equality constraints), such that \texttt{pi[k]} is the pointer to the first element of the vector $\pi_k$, and \texttt{pi[k][0]} is the first element of the vector $\pi_k$.
		The vector referenced by the pointer \texttt{pi[k]} is stored in a vector of \texttt{nx[k+1]$\times$1} floating-point numbers.
		\item[lam] is the vector of size $N+1$ of the pointers to the first element of the vectors $\lambda_k$ (Lagrange multipliers of the inequality constraints), such that \texttt{lam[k]} is the pointer to the first element of the vector $\lambda_k$, and \texttt{lam[k][0]} is the first element of the vector $\lambda_k$.
		The vector referenced by the pointer \texttt{lam[k]} is stored in a vector of \texttt{(2*nb[k]+2*ng[k])$\times$1} floating-point numbers, corresponding to (in the same order) \texttt{lb}, \texttt{ub}, \texttt{lc}, \texttt{uc}, \ldots
	\end{description}
	\item[args] is the pointer to a structure of type \texttt{ocp\_qp\_NAME\_args} that defines the arguments (as e.g. maximum number of iterations, minimum step size, \ldots) passed to the specific solver.
	\item[work] is the pointer to the working space used by the specific solver.
The working space size (in bytes) is returned by a call to the function 
\begin{verbatim}
ocp_qp_NAME_workspace_size_bytes(int N, int *nx, int *nu, 
    int *nb, int *nc, int **idxb, 
    ocp_qp_NAME_args *args)}. 
\end{verbatim}
\end{description}

\subsection{Examples}

\subsubsection{MPC problem}

In the MPC problem, the initial state is fixed.
This can be modeled by choosing \texttt{nx[0]=0}, i.e. not considering the initial state as an optimization variable.
As a consequence, e.g. the matrix \texttt{A[0]} has size \texttt{nx[1]$\times$0}, the matrix \texttt{Q[0]} has size \texttt{0$\times$0}, and the vector \texttt{q[0]} has size \texttt{0$\times$1}.
The information about the known value of $x_0$ and the matrix $A_0$ are used to compute the value of the vector \texttt{b[0]}, that is initialized to $b_0 + A_0 \cdot x_0$.

\section{Condensing Interface}

This is the interface to the condensing routine, first discovered in~\cite{Bock1984}. The notation used here is partly based on~\cite{Frasch2014a}.

Condensing consists of going from an OCP QP as in~\eqref{eq:OCP_QP} to a smaller QP of the form:
\begin{subequations}
	\label{eq:condensed_QP}
	\begin{alignat}{3}
	\underset{v \in \mathbb{R}^{n_v}}{\mathrm{minimize}} \quad & v^\top H v + h^\top v \\
	\mathrm{subject~to} \quad & l_v \leq v \leq u_v, \\
	& l_A \leq A v \leq u_A.
	\end{alignat}
\end{subequations}

Important intermediate quantities are the transition matrix and the transition vector
\begin{equation}
G = \begin{bmatrix}
G_{0,0} \\
G_{1,0} & G_{1,1} \\
\vdots & & \ddots \\
G_{N-1,0} & G_{N-1,1} & \cdots & G_{N-1,N-1}
\end{bmatrix}, \quad g = \begin{bmatrix}
g_0 \\
g_1 \\
\vdots \\
g_{N-1}
\end{bmatrix}
\end{equation}
and the matrix of general polytopic constraints
\begin{equation}
D = \begin{bmatrix}
D_{0,0} \\
D_{1,0} & D_{1,1} \\
\vdots & & \ddots \\
D_{N-1,0} & D_{N-1,1} & \cdots & D_{N-1,N-1} \\
D_{N,0} & D_{N,1} & \cdots & D_{N,N-1}
\end{bmatrix}.
\end{equation}
The condensed constraint matrix $A$ is formed by concatenating $G$ and $D$ stage-wise (if a certain stage has no simple state bounds or polytopic constraints, leave out the corresponding block row of $G$ or $D$, respectively):
\begin{equation}
A = \begin{bmatrix}
D_{0,0} \\
G_{0,0} \\
D_{1,0} & D_{1,1} \\
G_{1,0} & G_{1,1} \\
\vdots & & \ddots \\
D_{N-1,0} & D_{N-1,1} & \cdots & D_{N-1,N-1} \\
G_{N-1,0} & G_{N-1,1} & \cdots & G_{N-1,N-1} \\
D_{N,0} & D_{N,1} & \cdots & D_{N,N-1}.
\end{bmatrix}
\end{equation}

\subsection{The \texttt{C} interface}
\begin{verbatim}
int condensing_NAME(
    condensing_in *input, condensing_out *output, 
    condensing_workspace *work);
\end{verbatim}

\subsection{Return value}
TODO

\subsection{Data}
The condensing function relies on different structures, explained next.
\begin{description}
	\item[condensing\_in] The condensing input struct has only one field:
	\begin{description}
		\item[ocp\_qp\_input] is a struct defining the QP with optimal control structure, see Section~\ref{sec:OCP_QP_interface_data}.
	\end{description}
	\item[condensing\_out] The condensing output struct has the following fields:
	\begin{description}
		\item[H] is the pointer to the first element of the condensed Hessian matrix, in column major format.
		\item[h] is the pointer to the first element of the condensed gradient vector.
		\item[lb] is the pointer to the first element of the vector with lower bounds for the variables of the condensed problem.
		\item[ub] is the pointer to the first element of the vector with upper bounds for the variables of the condensed problem.
		\item[A] is the pointer to the first element of the polytopic constraint matrix for the condensed problem, in column major format.
		\item[lbA] is the pointer to the first element of the vector of lower bounds for the polytopic constraints.
		\item[ubA] is the pointer to the first element of the vector of upper bounds for the polytopic constraints.
	\end{description}
	\item[workspace] The condensing workspace struct has the following fields:
	\begin{description}
		\item[nconvars] is the number of variables of the condensed problem.
		\item[nconstraints] is the number of polytopic constraints of the condensed problem.
		\item[nstate\_bounds] is the vector of size $N+1$ of the number of simple state bounds in each stage.
		\item[G] is the vector of size $N$ of pointers to vectors of size $1 \ldots N$ of pointers to the first element of the matrix $G_{i,j}$, such that \texttt{G[i][j]} is the pointer to the first element of the matrix $G_{i,j}$, in column major format.
		\item[g] is the vector of size $N$ of pointers to the first element of the vector $g_i$, such that \texttt{g[i]} is the pointer to the first element of the vector $g_i$.
		\item[D] is the vector of size $N+1$ of pointers to vectors of size $1 \ldots N, N$ of pointers to the first element of the matrix $D_{i,j}$, such that \texttt{D[i][j]} is the pointer to the first element of the matrix $D_{i,j}$, in column major format. Note that both \texttt{D[N-1]} and \texttt{D[N]} are vectors of size $N$.
		\item[W1\_x] is the pointer to the first element of a helper matrix of size $n_x \times n_x$, in column major format.
		\item[W2\_x] is the pointer to the first element of a helper matrix of size $n_x \times n_x$, in column major format.
		\item[W1\_u] is the pointer to the first element of a helper matrix of size $n_x \times n_u$, in column major format.
		\item[W2\_u] is the pointer to the first element of a helper matrix of size $n_x \times n_u$, in column major format.
		\item[w1] is the pointer to the first element of a helper vector of size $n_x$.
		\item[w2] is the pointer to the first element of a helper vector of size $n_x$.
		\item[Sx0] is the pointer to the first element of a helper vector of size $n_u$.
	\end{description}
\end{description}

\section{Integrator Interface with Sensitivity Propagation}

\subsection{The \texttt{C} interface}
The interface looks like
\begin{verbatim}
int integrator_NAME(integrator_in *input, 
      struct integrator_NAME_opts *opts, double *work);
\end{verbatim}
where \texttt{NAME} is the name of the specific integration routine. Additionally, a function struct has been defined as:
\begin{verbatim}
typedef struct function_call_{
int dimIn, int dimOut, bool *sparsity, bool linear, 
void (*fun)(double*,double*), void (*jac)(double*,double*), 
bool forward, bool backward, bool hessian,
void (*vde_forw)(double*,double*), void (*vde_adj)(double*,double*),
void (*vde_hess)(double*,double*)} function_call;
\end{verbatim}
If we like the latter embedding of structs, we can avoid some of the fields in the $integrator\_in$ struct by moving them somewhere else!

\subsection{Return value}
The integrator function \texttt{integrator\_NAME} returns an integer number, that is defined in the following enumeration:
\begin{description}
	\item[ACADOS\_SUCCESS] Solution successfully found.
	\item[ACADOS\_MAXITER] Maximum number of integration steps reached.
	\item[ACADOS\_MINSTEP] Minumum step size reached.
\end{description}

\subsection{Data}
The input struct is defined as:
\begin{verbatim}
typedef struct integrator_in_{
    int nSteps, int nSystems, int nX, int nXA, int nP, int nOD, 
    double *steps, int *nx, int *nxa, double **S0, double *mu,
    double **x, double **xa, double *p, double *od, double **xOut, 
    double **sensOut, double *muOut, double *hessOut, int nOutputs,
    int *nGridOutputs, double **gridOutputs, double **muOutputs, 
    double **valOutputs, double **sensOutputs, function_call *sys, 
    function_call *out, double *variables} integrator_in;
\end{verbatim}

\begin{description}
\item[] \textcolor{red}{For fixed step integrators:}
\item[nSteps] [input] is the number of integration steps (in case of no step size control).
\item[steps] [input] is the vector of size $nSteps$, containing the step size for each integration step.
\item[] \textcolor{red}{Dimensions of the dynamic system(s):}
\item[nSystems] [input] is the number of dynamic subsystems in order of dependency (states of subsystem $k$ only depend on subsystems $1,2,\ldots, k-1$ etc).
\item[flag\_linear] [input] is the vector of size $nSystems$, containing the flag whether the subsystem is linear or not ($0$ or $1$, should be part of options OR see the function\_call struct).
\item[nx] [input] is the vector of size $nSystems$, containing the number of differential states for this integrator.
\item[nxa] [input] is the vector of size $nSystems$, containing the number of algebraic states for this integrator.
\item[nX] [input] is the {\bf total} number of differential states for this integrator.
\item[nXA] [input] is the {\bf total} number of algebraic states for this integrator.
\item[nP] [input] is the number of free parameters for this integrator (sensitivities with respect to these parameters are computed).
\item[nOD] [input] is the number of online data, i.e. fixed parameters for this integrator (no sensitivities are computed).
\item[] \textcolor{red}{Sensitivity analysis for the integrator:}
\item[S0] [input] is the vector of size $nSystems$ of the pointers to the matrices containing the forward seeds (the dimensions of these matrices are $nx[0] \times (nx[0]+np)$, $nx[1] \times (nx[0]+nx[1]+np)$, $\ldots$ etc).
\item[mu] [input] is the vector of dimension $nX$, containing the backward seed.
\item[flag\_forward] [input] is the flag for first order forward sensitivity propagation ($0$ or $1$, should be part of options OR see the function\_call struct).
\item[flag\_backward] [input] is the flag for first order backward sensitivity propagation ($0$ or $1$, should be part of options OR see the function\_call struct).
\item[flag\_hessian] [input] is the flag for second order Hessian propagation ($0$ or $1$, should be part of options OR see the function\_call struct).
\item[] \textcolor{red}{Input and output data to the integrator:}
\item[x] [input] is the vector of size $nSystems$ of the pointers to the initial values of the differential states for this integrator.
\item[xOut] [output] is the vector of size $nSystems$ of the pointers to the end values of the differential states as a result of calling this integrator.
\item[sensOut] [output] is the vector of size $nSystems$ of the pointers to the end values of the forward sensitivities as a result of calling this integrator.
\item[muOut] [output] is the vector of size $nX+nP$ containing the backward derivatives as a result of calling this integrator.
\item[hessOut] [output] is the matrix of size $(nX+nP) \times (nX+nP)p$ containing the second order derivatives as a result of calling this integrator.
\item[xa] [input,output] is the vector of size $nSystems$ of the pointers to the initial {\bf guess} of the algebraic states for this integrator (the guess can be updated by the integrator).
\item[p] [input] is the vector of size $nP$ containing the free parameters for this integrator (sensitivities can be computed).
\item[od] [input] is the vector of size $nOD$ containing the online data, i.e. fixed parameters for this integrator (no sensitivities are computed).
\item[] \textcolor{red}{Extra outputs to be evaluated:}
\item[nOutputs] [input] is the number of extra output functions (with each their own dimension).
\item[dimOutputs] [input] is the vector of size $nOutputs$, containing the dimension for each of the output functions (moved to function\_call struct!).
\item[sparsityOutputs] [input] is the matrix of dimension $nOutputs \times (nX+nXA+nX)$, defining the sparsity pattern for each output function with respect to the differential states, the algebraic variables and the state derivatives (moved to function\_call struct!).
\item[nGridOutputs] [input] is the vector of size $nOutputs$, containing the number of grid points on which each output function should be evaluated.
\item[gridOutputs] [input] is the vector of size $nOutputs$ of the pointers to the grid points on which each output function should be evaluated.
\item[muOutputs] [input] is the vector of size $nOutputs$ of the pointers to the backward seeds for each of the grid points defined by $gridOutputs$.
\item[valOutputs] [output] is the vector of size $nOutputs$ of the pointers to the outputs evaluated on the grid points defined by $gridOutputs$.
\item[sensOutputs] [output] is the vector of size $nOutputs$ of the pointers to the forward sensitivities of the outputs evaluated on the grid points defined by $gridOutputs$.
\item[] \textcolor{red}{The functions (including AD) to be evaluated:}
\item[] (This changed using the  function\_call struct!!)
\item[rhs] [input] the function pointer to evaluate the right-hand side.
\item[jac] [input] the function pointer to evaluate the full Jacobian.
\item[vde\_forw] [input] the function pointer to evaluate the forward variational differential equations.
\item[vde\_adj] [input] the function pointer to evaluate the adjoint equations.
\item[vde\_hess] [input] the function pointer to evaluate the second order sensitivity equations.
\item[out\_vde\_forw] [input] is the vector of size $nOutputs$, containing the function pointers to evaluate the forward sensitivity equations for the outputs.
\item[out\_vde\_adj] [input] is the vector of size $nOutputs$, containing the function pointers to evaluate the adjoint equations for the output functions.
\item[out\_vde\_hess] [input] is the vector of size $nOutputs$, containing the function pointers to evaluate the second order sensitivity equations for the outputs.
\item[] \textcolor{red}{Other memory:}
\item[variables] [input,output] is the pointer to the warm variables space used by the specific solver from one call to the other.
The variables space size (in doubles) is returned by a call to the function \\\texttt{integrator\_NAME\_variables\_double(integrator\_in *input, struct integrator\_solver\_opts *opts)}. 
\item[opts] [input] is the pointer to a structure of type \texttt{integrator\_NAME\_opts} that defines the arguments (as e.g. maximum number of steps, minimum step size, desired tolerance, \ldots) passed to the specific solver.
\item[work] [workspace] is the pointer to the working space used by the specific solver.
The working space size (in doubles) is returned by a call to the function \texttt{integrator\_NAME\_workspace\_double(integrator\_in *input, struct integrator\_solver\_opts *opts)}. 
\end{description}

\bibliographystyle{abbrv}
\bibliography{../syscop.bib}


\end{document}
